import Vue from 'vue';
import Router from 'vue-router';
Vue.use(Router);
/* Layout */
import Layout from '@/layout';
/* Router Modules */
// import componentsRouter from './modules/components'
// import chartsRouter from './modules/charts'
// import tableRouter from './modules/table'
// import nestedRouter from './modules/nested'

var constantRoutess = [

	{
	    path: '/',
	    component: () => import('@/views/login/index'),
	    hidden: true
	},

  {
    path:'/home',
    component:Layout,
    redirect:'/home/index',
    meta: { title:'首页',icon:'dashboard',affix:false},
    children: [
      {
        path:'index',
        component: () => import('@/views/dashboard/index.vue'),
        name:'index',
        meta:{title:'首页',affix:false }
      },
    ]
  },

  {
    path:'/msg',
    component:Layout,
    redirect:'/msg/msgindex',
    meta: { title:'消息中心',icon:'message',affix:false},
    children: [
      {
        path:'msgindex',
        component: () => import('@/views/MessageCenter/index.vue'),
        name:'msgindex',
        meta:{title:'消息中心',affix:false }
      },
    ]
  },

		{
		     path:'/userhome',
		     component:Layout,
		     redirect:'/userhome/user',
			   meta: { title:'用户管理',icon:'chart',affix:false},
		     children: [
				  {
				    path:'user',
				    component: () => import('@/views/user/user_index.vue'),
				    name:'user',
				    meta:{title:'用户管理',affix:false }
				  }
		     ]
		},


  //  {
  //   path:'/declare',
  //   component:Layout,
  //   redirect:'/declare/Inventory_request',
  //   meta: { title:'申报管理',icon:'form',affix:false},
  //   children: [
  //     {
  //       path:'Inventory_request',
  //       component: () => import('@/views/DeclaMan/Inventory_request.vue'),
  //       name:'Inventory_request',
  //       meta:{title:'库存申请',affix:false }
  //     },
  //     {
  //       path:'Application_record',
  //       component: () => import('@/views/DeclaMan/Application_record.vue'),
  //       name:'Application_record',
  //       meta:{title:'申请记录',affix:false }
  //     },
  //   ]
  //  },
  // {
  //   path:'/cggl',
  //   component:Layout,
  //   redirect:'/cggl/pro',
  //   meta: { title:'采购管理',icon:'shopping',affix:false},
  //   children: [
  //     {
  //       path:'ProcurementManagement',
  //       component: () => import('@/views/Procur/ProcurementManagement.vue'),
  //       name:'Inventory_request',
  //       meta:{title:'采购审核管理',affix:false }
  //     },
  //     {
  //       path:'cgjl',
  //       component: () => import('@/views/Procur/cgjl.vue'),
  //       name:'cgjl',
  //       meta:{title:'采购审核记录',affix:false }
  //     },
  //   ]
  // },
  {
    path: '/stock',
    component: Layout,
    redirect: '/inventory',
    meta: { title: '库存管理', affix: false ,icon:'component'},
    children: [
      {
        path: 'inventory',
        component: () => import('@/views/stock/inventory.vue'),
        name: 'inventory',
        meta: { title: '库存盘点', affix: false }
      },
      // {
      //   path: 'warehousing',
      //   component: () => import('@/views/stock/warehousing.vue'),
      //   name: 'warehousing',
      //   meta: { title: '入库管理', affix: false }
      // },
      // {
      //   path: 'delivery',
      //   component: () => import('@/views/stock/delivery.vue'),
      //   name: 'delivery',
      //   meta: { title: '出库管理', affix: false }
      // },
	  {
	    path: 'InandOut',
	    component: () => import('@/views/stock/InandOut.vue'),
	    name: 'InandOut',
	    meta: { title: '出/入库记录', affix: false }
	  },
    ]
  },

	// {
	//     hidden: true,//当设置 true 的时候该路由不会再侧边栏出现
	// 	title:'发布文章',
	// 	component: Layout,
	// 	path: '/add_wen',
	// 	children: [
	// 	       {
	// 	         path: '/add_wen',
	// 	         component: () => import('@/views/jifen_yin/add_wen'),
	// 	         name: 'add_wen',
	// 	         meta: {title:'发布文章',affix:false}
	// 	       },
	// 	]
	// },


]


if (localStorage.role == 3) {
  // if(constantRoutess[constantRoutess.length-1].path=='/setting'){
	  // constantRoutess.splice(constantRoutess.length-1,1);
  // }
	// console.log(localStorage.role,constantRoutess,'用户身份');
}else{

	// if(constantRoutess[constantRoutess.length-1].path!='/setting'){
		  // constantRoutess.push(a)
	// }

}

export var constantRoutes = constantRoutess;

/**
 * asyncRoutes
 * the routes that need to be dynamically loaded based on user roles
 */
export const asyncRoutes = [


    // 404 page must be placed at the end !!!
    // { path: '*', redirect: '/404', hidden: true }
];

const createRouter = () => new Router({
    // mode: 'history', // require service support
    scrollBehavior: () => ({y: 0}),
    routes: constantRoutes
});

const router = createRouter()

// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
    const newRouter = createRouter()
    router.matcher = newRouter.matcher // reset router
}

export default router;
